Harden assignment sync to prevent disappearing assignments#43
Harden assignment sync to prevent disappearing assignments#43digital-pro wants to merge 2 commits intomainfrom
Conversation
Normalize and validate administration data before persistence, sanitize assignment write payloads in fan-out paths, and document the disappearing-assignment issue with root cause and mitigation details. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep only the functional disappearing-assignment hardening changes and drop formatting-only edits from touched files. Co-authored-by: Cursor <cursoragent@cursor.com>
asengupta3
left a comment
There was a problem hiding this comment.
I think this is a partial solution. I think the main issue is the async operation that you have mentioned in the README. Also, we should not be committing README's for every bug. They should be a part of the issue description. Please look at this PR:
#20
and the comments there. I think the real solution is to get that PR working and merged. That should give us more clarity and more accuracy.
|
Chrissy and Amy were having a hard time recreating this task so I wrote a batch tester to run their scenario a bunch and get it to fail. Then I had the test generate a fix and document it. I posted that on the channel, but didn't document it here. The idea was that someone could take a look at this as POC and build from there. No intention to checkin the README, for starters. Just there as a reference for whomever knows enough to do the right thing. I need to make that more clear in the name of the PR! |
Summary
functions/levante-admin/README_DISAPPEARING_ASSIGNMENTS.mdIssue context
Users reported that assignment creation could appear successful while one or more users were missing assignment docs. Investigation showed two categories:
userType == student)This PR addresses category (2) directly by preventing malformed data from reaching Firestore write paths.
What changed
functions/levante-admin/src/upsertAdministration.tsassessment.paramsto object shapetaskId,variantId,variantName)createdByon updatesfunctions/levante-admin/src/assignments/assignment-utils.tstransaction.set(...)in add/update fan-out pathsfunctions/levante-admin/src/utils/utils.tsremoveUndefinedFields()to recursively clean nested arrays (not only top-level undefined entries)Documentation
functions/levante-admin/README_DISAPPEARING_ASSIGNMENTS.mdwith:Why this should fix the issue
Assignment fan-out (
updateAssignmentsForOrgChunk) is asynchronous and can fail on malformed write payloads. This patch sanitizes and validates data both at ingress (upsertAdministration) and immediately before assignment writes, reducing partial/failed propagation caused by undefined and malformed fields.Test plan
Related support-side change
levante-supportbug-806 test update was pushed directly tomainto align test expectations with assignment conditions and keep assignment audit artifacts.Made with Cursor